package com.example.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class LoginActivity extends Activity {
    EditText et_loginUser,et_loginPassword;
    Button bt_login;
    String userName,password;
    TextView bt_signIn;
    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        et_loginUser=findViewById(R.id.et_loginUser);
        et_loginPassword=findViewById(R.id.et_loginPassword);
        bt_login=findViewById(R.id.bt_login);
        bt_signIn=findViewById(R.id.bt_signIn);
        bt_login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getEditString();
                if(TextUtils.isEmpty(userName)){
                    Toast.makeText(LoginActivity.this, "请输入用户名", Toast.LENGTH_SHORT).show();
                    return;
                }else if(TextUtils.isEmpty(password)){
                    Toast.makeText(LoginActivity.this, "请输入密码", Toast.LENGTH_SHORT).show();
                    return;
                }else{
                    Intent it=new Intent();
                    it.setClass(LoginActivity.this,FindActivity.class);
                   LoginActivity.this.startActivity(it);
                }
            }
        });
        bt_signIn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent it=new Intent();
                it.setClass(LoginActivity.this,RegisterActivity.class);
                LoginActivity.this.startActivity(it);
            }
        });
    }
    private void getEditString(){
        userName=et_loginUser.getText().toString().trim();
        password=et_loginPassword.getText().toString().trim();
    }
}
